<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Http\Services\MessageFetch\FetchWorker\DailyWoolWorkerLocal;

class DailyWorkerPush extends Command
{
    /**
     * The name and signature of the console command.
     * run: php artisan command:DailyWorkerPush.
     *
     * @var string
     */
    protected $signature = 'command:DailyWorkerPush';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        while (true) {
            try {
                $cls = (new DailyWoolWorkerLocal());
                $cls->handle();
                echo '【success】' . $cls->txt . PHP_EOL . PHP_EOL;
                //休息1-3分钟随机
                sleep(rand(20, 120));
            } catch (\Exception $exception) {
                echo '【error】' . $exception->getMessage() . PHP_EOL . PHP_EOL;
            }
        }
    }
}
